$(function () {
    validateData();
    saveUpdatePlace();
    $('body').on('click', '#onBack', function () {
        onBackHistory();
    });
})

/**
 * 取消
 */
function onBackHistory() {
    window.history.go(-1);
}

function saveUpdatePlace() {
    $('body').on('click','#submitGroomPlace',function () {
        var placeName=$('input[name="placeName"]').val();
        if(placeName==null||placeName==''){
            icModale(0,"推荐名称不能为空");
            return;
        }
        var groomNum = $('input[name="groomNum"]').val();
        if(groomNum==null||groomNum<=0){
            icModale(0, "限制数量不能为空");
            return;
        }
        if(isNumber(groomNum)==false){
            icModale(0,"限制数量只能为正整数");
            return;
        }
        var depict = $('textarea[name="depict"]').val();
        if(depict==null||depict==''){
            icModale(0,"推荐位置描述不能为空");
            return;
        }
        var params = $("#saveGroomPlaceFrom").serializeJSON();
        params = JSON.stringify(params);
        $.ajax({
            url:baseloaction+"/admin/op/groom/ajaxSaveUpdateGroomPlace",
            type:"post",
            data:params,
            dataType:"json",
            contentType:'application/json;charset=utf-8',
            success:function (result) {
                if(result.success==true){
                    icModale(1,result.message,1,function () {
                        window.location.href=baseloaction+"/admin/op/groom/queryGroomPlaceList";
                    });
                }else{
                    icModale(0, result.message);
                }
            },
            error:function (error) {
                icModale(0, "系统繁忙，请稍后再试");
            }
        });
    })
}